import { defineStore } from "pinia";
import type { Users } from "@/api/user";

interface userStoreType {
  token: string;
  userInfo: Users | null | undefined;
}

const userStore = defineStore("user", {
  state: (): userStoreType => {
    return {
      token: "",
      userInfo: null,
    };
  },
  persist: process.client && {
    // 仅在客户端使用
    storage: localStorage, // localStorage 本地存储，可替换sessionStorage
  },
});

export default userStore;
